<template>
    <div>
        <a-result
                status="success"
                title="登录成功"
                sub-title="请选择是否使用第三方登录，或者点击取消返回登录界面"
        >
            <template #extra>
                <a-button type="primary" @click="goIndex">
                    前往首页
                </a-button>
                <a-button @click="goLogin">
                    取消
                </a-button>
            </template>
        </a-result>
    </div>
</template>

<script>
    import {weiboLogin} from "@/api/auth/oauth2";

    export default {
        name: "oauth2",
        data() {
            return {}
        },
        methods: {
            async goIndex() {
                const code = this.$route.query.code
                console.log(code)
                const data = await weiboLogin(code)
                if (data != null) {
                    await this.$router.push({
                        name: 'index',
                        query: data
                    })
                }
            },
            goLogin() {
                this.$router.push("login")
            }

        }
    }
</script>

<style scoped>

</style>
